<template>
  <drag-dialog
    title="富文本默认值设置"
    v-model="show"
    @close="close"
    width="60%"
    append-to-body
    :close-on-click-modal="false"
    :close-on-press-escape="false"
  >
    <vue-quill-editor ref="editor" v-model="content" />
    <template #footer>
      <dialog-footer @ok="submit" @cancel="close" />
    </template>
  </drag-dialog>
</template>

<script>
export default {
  // components: { vueQuillEditor },
  // model: {
  //   prop: "data",
  //   event: "changeValue",
  // },
  props: {
    data: {
      type: Boolean,
      default: false
    },
    defaultValue: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      content: '',
      show: false
    }
  },
  watch: {
    data: {
      handler(newVal) {
        this.show = newVal
      },
      immediate: true
    },
    defaultValue: {
      handler(newVal) {
        this.content = newVal
      },
      immediate: true
    }
  },
  methods: {
    submit() {
      const html = this.$refs.editor.getHtml()
      this.$emit('submit', html)
      this.close()
    },
    close() {
      this.show = false
      this.$emit('update:data', this.show)
    }
  }
}
</script>
